*Replication of results from experimental pretest for Appendix 2
*August 2021

version 12.1
set more off
clear all
estimates clear

*Load data
*Set command dictionary to location where replication files are saved.
	*cd
use "experiment/pretest.dta", clear


*Figure A2.1 Assumptions about Military Affiliation by Treatment
	*Wilson is Part of US Military
	mean partmil if miltreat==0
	est store Civilian
	mean partmil if miltreat==1
	est store Military

	coefplot Military Civilian, vertical ciopts(recast(rcap)) scheme(s1mono) /// 
		title("Wilson Is Part of US Military") /// 
		xtitle("Treatment") ytitle ("Proportion of Respondents") /// 
		xlabel(none) name(partofmil)

		*Comparison of proportions reported in text: Part of military by treatment
		prtest partmil, by(miltreat)
	
	*Wilson had Combat Experience
	mean combatexp if miltreat==0
	est store Civilian
	mean combatexp if miltreat==1
	est store Military

	coefplot Military Civilian, vertical ciopts(recast(rcap)) scheme(s1mono) /// 
		title("Wilson Had Combat Experience") /// 
		xtitle("Treatment") ytitle ("Proportion of Respondents") /// 
		xlabel(none) name(combat)
	
		*Comparison of proportions reported in text: Combat experience by treatment
		prtest combatexp, by(miltreat)
	
	*Wilson is Active Duty
	mean active if miltreat==0
	est store Civilian
	mean active if miltreat==1
	est store Military

	coefplot Military Civilian, vertical ciopts(recast(rcap)) scheme(s1mono) /// 
		title("Wilson Is Active Duty") /// 
		xtitle("Treatment") ytitle ("Proportion of Respondents") /// 
		xlabel(none) name(activeduty)

		*Comparison of proportions reported in text: Active duty by treatment
		prtest active, by(miltreat)
	
		*No difference in approval based on active duty assumptions
		prtest approve if miltreat==1, by(active)
		prtest approve if miltreat==0, by(active)
		prtest approve, by(active)
	
	*Wilson has Expertise in Management of National Security
	mean expertise if miltreat==0
	est store Civilian
	mean expertise if miltreat==1
	est store Military

	coefplot Military Civilian, vertical ciopts(recast(rcap)) scheme(s1mono) /// 
		title("Wilson has Expertise in Management of National Security") /// 
		xtitle("Treatment") ytitle ("Proportion of Respondents") /// 
		xlabel(none) name(natsecexpert)
	
		*Comparison of proportions reported in text: Expertise by treatment
		prtest expertise, by(miltreat)
	
	*Combine plots to make Figure A2.1
	graph combine partofmil combat activeduty natsecexpert, /// 
		ycommon altshrink graphregion(fcolor(white) ifcolor(white)) /// 
		plotregion(fcolor(white) lcolor(white) ilcolor(white)) rows(2) /// 
		title("Military Affiliation", style(medium))
	graph export "results/fig_a2_1.pdf", as(pdf) replace


*Figure A2.2 Perceptions of Legitimacy and Risk by Treatment
	
	*View Intervention as Legitimate
	
	/* The "legit" variable was created using the following code:
		local legitvar engage_mil_legit engage_civ_legit out_mil_legit /// 
		out_civ_legit success_mil_legit success_civ_legit fail_mil_legit /// 
		fail_civ_legit

		gen legit=.
			foreach l of local legitvar {
				replace legit=0 if `l'==2
				replace legit=0 if `l'==4
				replace legit=1 if `l'==3
				replace legit=1 if `l'==5
				}
				tab legit */
	
	mean legit if miltreat==0
	est store Civilian
	mean legit if miltreat==1
	est store Military

	coefplot Military Civilian, vertical ciopts(recast(rcap)) scheme(s1mono) /// 
		title("View Intervention as Legitimate") /// 
		xtitle("Treatment") ytitle ("Proportion of Respondents") /// 
		xlabel(none) name(legitimacy)

		*Comparison of proportions reported in text: Legitimacy by treatment
		prtest legit, by(miltreat)
	
	*View Intervention as Risky
	
	/*The "risk" variable was created using the following code:
		local riskvar engage_mil_risk engage_civ_risk out_mil_risk out_civ_risk /// 
		success_mil_risk success_civ_risk fail_mil_risk fail_civ_risk

		gen risk=.
			foreach r of local riskvar {
				replace risk=0 if `r'==3
				replace risk=0 if `r'==5
				replace risk=1 if `r'==2
				replace risk=1 if `r'==4
				}
				tab risk */

	mean risk if miltreat==0
	est store Civilian
	mean risk if miltreat==1
	est store Military

	coefplot Military Civilian, vertical ciopts(recast(rcap)) scheme(s1mono) /// 
		title("View Intervention as Risky") /// 
		xtitle("Treatment") ytitle ("Proportion of Respondents") /// 
		xlabel(none) name(levelofrisk)
	
		*Comparison of proportions reported in text: Risk by treatment
		prtest risk, by(miltreat)

	*Combine legitimacy and risk panels to make figure A2.2	
	graph combine legitimacy levelofrisk, ycommon altshrink /// 
		graphregion(fcolor(white) ifcolor(white)) /// 
		plotregion(fcolor(white) lcolor(white) ilcolor(white)) rows(1) /// 
		title("Stakes of Intervention", style(medium))
	graph export "results/fig_a2_2.pdf", as(pdf) replace
